package com.ruoyi.web.controller.webs.ky450;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.ky450.service.IEquipMissileService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ky450.domain.EquipMissile;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 导弹Controller
 *
 * @author ruoyi
 * @date 2025-01-16
 */
@RestController
@RequestMapping("/webs/equipMissile")
public class EquipMissileController extends BaseController
{
    @Autowired
    private IEquipMissileService equipMissileService;

    /**
     * 查询导弹列表
     */
    //@PreAuthorize("@ss.hasPermi('system:missile:list')")
    @GetMapping("/list")
    public TableDataInfo list(EquipMissile equipMissile)
    {
        startPage();
        List<EquipMissile> list = equipMissileService.selectEquipMissileList(equipMissile);
        return getDataTable(list);
    }

    /**
     * 导出导弹列表
     */
    //@PreAuthorize("@ss.hasPermi('system:missile:export')")
    //@Log(title = "导弹", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EquipMissile equipMissile)
    {
        List<EquipMissile> list = equipMissileService.selectEquipMissileList(equipMissile);
        ExcelUtil<EquipMissile> util = new ExcelUtil<EquipMissile>(EquipMissile.class);
        util.exportExcel(response, list, "导弹数据");
    }

    /**
     * 获取导弹详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:missile:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(equipMissileService.selectEquipMissileById(id));
    }

    /**
     * 新增导弹
     */
    //@PreAuthorize("@ss.hasPermi('system:missile:add')")
    //@Log(title = "导弹", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EquipMissile equipMissile)
    {
        return toAjax(equipMissileService.insertEquipMissile(equipMissile));
    }

    /**
     * 修改导弹
     */
    //@PreAuthorize("@ss.hasPermi('system:missile:edit')")
    //@Log(title = "导弹", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EquipMissile equipMissile)
    {
        return toAjax(equipMissileService.updateEquipMissile(equipMissile));
    }

    /**
     * 删除导弹
     */
    //@PreAuthorize("@ss.hasPermi('system:missile:remove')")
    //@Log(title = "导弹", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(equipMissileService.deleteEquipMissileByIds(ids));
    }
}
